<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "cnc_join".
 *
 * @property integer $channel_id
 * @property integer $content_id
 */
class Cncjoin extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'cnc_join';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['channel_id', 'content_id'], 'integer']
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'channel_id' => 'Channel ID',
            'content_id' => 'Content ID',
        ];
    }
    public function saveCnc($id){
        $arr=Yii::$app->request->post();
        $connection=yii::$app->db;
        $arr['Content']['channel_id']=$arr['Content']['channel_id']==NULL ? array():$arr['Content']['channel_id'];
        foreach ($arr['Content']['channel_id'] as $k => $v){
            $connection->createCommand()->batchInsert('cnc_join', ['channel_id', 'content_id'], [
                [$v, $id],
            ])->execute();
        }
        return true;
    }
}
